package 力扣日常刷题.木22二月.第02天207;

/**
 * @author 帅小伙
 * @date 2022/2/7
 * @description
 * 动态规划
 * 压缩数组
 */
public class Demo24把数字翻译成字符串 {

    public int translateNum(int num) {
        String src = String.valueOf(num);
        int p = 0 , q = 0, r = 1;
        for (int i = 0; i < src.length(); i++) {
            p = q;
            q = r;
            r = 0;
            r +=q;
            if(i == 0) continue;
            String pre = src.substring(i-1,i+1);
            if(pre.compareTo("25") <= 0 && pre.compareTo("10") >= 0){
                r += p;
            }
        }
        return r;
    }

}
